﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace calkulators
{
    
    public class kalkulator
    {
        public double operant1;
        public double operant2;
        public double rezult;
        //public void dot()
        //{
        //}
        
        
    }

    public class trigonom : kalkulator
    {
        public void ravnoTR(string a)
        {
            if (a == "sin")
                rezult = sin();
            if (a == "cos")
                rezult = cos();
            if (a == "tg")
                rezult = tg();
            if (a == "ctg")
                rezult = ctg();
            
        }


        public double sin()
        {
            double operant;
            operant = Math.Sin(Math.PI * operant1 / 180);
            return operant;
        }
        public double cos()
        {
            double operant;
            operant = Math.Cos(Math.PI * operant1 / 180);
            return operant;
        }
        public double tg()
        {
            double operant;
            operant = Math.Tan(Math.PI * operant1 / 180);
            return operant;
        }
        public double ctg()
        {
            double operant;
            //operant = Math.Tan(Math.PI * operant1 / 180);
            if (sin() != 0)
                operant = cos() / sin();
            else
            {
                operant1 = -2;
                operant2 = -1;
                operant = 0;
                //operant = Convert.ToDouble(ConsoleKey.End);
            }
            return operant;
        }

    }

    public class arifm : kalkulator
    {
        public void ravnoAR(string a)
        {
            if (a == "+")
                rezult = plus();
            if (a=="-")    
                rezult=minus();
            if (a == "*")
                rezult = ymnog();
            if (a == "/")
                rezult = razdel();
            if (a=="^")
                rezult=stepen();   
            if (a=="sqrt")
                rezult=koren();
            //if (a == "sin")
            //    rezult = sin();
        }
        public double plus()
        {
            double operant = operant1 + operant2;
            return operant;  
        }
        public double minus()
        {
            double operant = operant1 - operant2;
            return operant; 
        }

        public double ymnog()
        {
            double operant = operant1 * operant2;
            return operant;
        }
        public double razdel()
        {
            double operant;
            if (operant1 != 0)
            {
                operant = operant1 / operant2;
            }
            else
            {
                operant1 = -2;
                operant2 = -1;
                operant = 0;
            }
            return operant;
        }

        public double koren()
        {
            double operant;
            if (operant1 >= 0)
                operant = Math.Sqrt(operant1);
            else
            {
                operant1 = -2;
                operant2 = -1;
                operant =  0;
                //operant = Convert.ToDouble(ConsoleKey.End);
            }
            return operant;
        }
        public double stepen()
        {
            double operant;
            operant = Math.Pow(operant1, operant2);
            return operant;
        }

    }
}